package com.xd.controller;/**
 * Created by mac on 2019/5/24.
 */

import com.xd.bean.User;
import org.springframework.web.bind.annotation.*;

/**
 * @author KANADE_XD
 * @date 2019/5/24 2:02 PM
 * @definition 作业五种传值
 */

@RestController

public class XdController {

    //地址传值
    @RequestMapping("/address/{text}")
    public String address(@PathVariable("id") String text) {
        return "获得的值为" + text;
    }

    //?传值
    @RequestMapping("/wh")
    public String wh(@RequestParam String text) {
        return "获得的值为" + text;
    }

    //body参数
    @PostMapping("/body")
    public String body(@RequestBody String text) {
        return "获得的值为" + text;
    }

    //form 提交
    @PostMapping("form")
    public String form(String text, String text2) {
        return "获得的text值为" + text + "获得的text2值为" + text2;
    }

    //ModelAttribute注释提交
    @PostMapping("/ma")
    public User ma(@ModelAttribute("user") User user) {
        return user;
    }

    //请求头参数以及Cookie
    @GetMapping("/handc")
    public String handc(@RequestHeader(name = "myHeader") String myHeader, @CookieValue(name = "myCookie") String myCookie) {
        return "header值为:" + myHeader + "cookie值为" + myCookie;
    }

}
